import count from '@dfeidao/atom-nodejs/db/count';
import query from '@dfeidao/atom-nodejs/db/query';
import log from '@dfeidao/atom-nodejs/logger/log';
import { systemid } from '../../atom/config';
import format from '@dfeidao/atom-nodejs/dt/format';
interface Message {
}
interface ms {
	v: string;
}


export default async function atom(msg: Message, action_id: string, session_id: string) {
	log('Service begin');
	// todo
	const op = await query(action_id, session_id, systemid);
	op.prepare("implement_record_sheet", ["record_number", "plan_number", "plan_name", "inspect_time", "place _of_ record"], { $like: '%%' }, 5, 1, [], []);
	const [res] = await op.exec();

	res.forEach((v: ms) => {// 把每个数据在赋值给v 添加到对象里
		let time = v["inspect_time"];
		let data = format(parseInt(time), "YYYY-MM-DD HH:mm:ss");
		v['inspect_time'] = data;
		v.v = JSON.stringify(v);
	});
	const co = await count(action_id, session_id, systemid);
	co.prepare("implement_record_sheet", { $like: '%%' });
	const t = await co.exec();
	log('Service end');
	return { res, t };


}

